#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <stdlib.h>
#include <unordered_map>
using namespace std;

bool paren_match(string str){
    if(str.length()%2)return false;
    unordered_map<char,char> pairs = {{')','('},{']','['},{'}','{'}};
    stack<char> stk;
    for(char s:str){
        if(pairs.count(s)){
            if(stk.empty()||stk.top()!=pairs[s])return false;
            stk.pop();
        }else{
            stk.push(s);
        }
    }
    return stk.empty();
}

int rev_polish_notation(vector<string>& tokens){
    stack<int> stk;
    int ans = -1;
    for(string str:tokens){
        if(isdigit(str[0])||str.length()>1){
            stk.push(stoi(str.c_str()));
        }else{
            int a = stk.top();
            stk.pop();
            int b = stk.top();
            stk.pop();
            if(str=="+") stk.push(a+b);
            if(str=="-") stk.push(a-b);
            if(str=="*") stk.push(a*b);
            if(str=="/") stk.push(a/b);
        }
    }
}

vector<int> maxSlidingWindow(vector<int>& nums, int k) {
    deque<int> q;
    q.push_back(0);
    vector<int> ans;
    for(int i=0;i<nums.size();i++){
        if (i-q.front()+1>k)q.pop_front();
        while(!q.empty()&&nums[q.back()]<=nums[i])q.pop_back();
        q.push_back(i);

        if(i>=k-1)ans.push_back(nums[q.front()]);
    }
    return ans;
}

int main(){
    string str = "([{}([])])";
    cout<<paren_match(str)<<endl;
    
}